package com.hualan.sfzy.controller.course;

import com.hualan.sfzy.entity.course.CourseClassify;
import com.hualan.sfzy.service.course.CourseClassifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class CourseClassifyController {
    @Autowired
    private CourseClassifyService courseClassifyService;
    @PutMapping("/courseclassify")
    public String updateCourseClassify(@RequestBody CourseClassify courseClassify) {
        return courseClassifyService.update(courseClassify)>0?"success":"fail";
    }
    @PostMapping("/courseclassify")
    public String add(@RequestBody CourseClassify courseClassify) {
        return courseClassifyService.add(courseClassify)>0?"success":"fail";
    }
    @DeleteMapping("/courseclassify/{id}")
    public String remove(@PathVariable int id) {
        return courseClassifyService.remove(id)>0?"success":"fail";
    }
    @DeleteMapping("/courseclassify")
    public String removeBatch(Integer[] ids) {
        return courseClassifyService.removeBatch(ids)>0?"success":"fail";
    }
    @GetMapping("/courseclassify")
    public List<CourseClassify> find() {
        return courseClassifyService.find();
    }
    @GetMapping("/courseclassify/{id}")
    public CourseClassify findById(@PathVariable int id) {
        return courseClassifyService.findById(id);
    }
    @GetMapping("/courseclassify/page")
    public Object findPage(

            @RequestParam(value = "pageNum",required = false,
                    defaultValue = "1")
            Integer pageNum,
            @RequestParam(value = "pageSize",required = false,defaultValue = "5")
            Integer pageSize,
            CourseClassify courseClassify
    ){
        return courseClassifyService.findPage(pageNum,pageSize,courseClassify);
    }

}

